/*****************************************************************************
 *
 * Copyright (c), 2004-2020,ShangHai Neotune Information Technology Co., Ltd.
 *
 * Module Name : decode.h
 *
 * Author :    sean
 *
 * Date :    2004-02-05
 *
 * Version :    1.00
 *
 * Description :    
 *
 * Other :    
 *
 * Data Structure List: <Main Data Structure>
 *
 * Modification History
 * ---------------------------------------------------------------------------
 *  1: Data :      2004-02-05
 *    Author :     sean
 *    Version :    V100R001M00
 *    Modification : creation
 *
*****************************************************************************/

#if (!defined(decode_inc))
#define decode_inc

#ifdef __cplusplus
extern"C" {
#endif

#if (!defined(asn1conf_inc))
#include <asn1conf.h>
#endif

#if (!defined(asn1_inc))
#include <asn1.h>
#endif

#if (!defined(localio_inc))
#include <localio.h>
#endif

#if (!defined(buffer_inc))
#include <buffer_snmp.h>
#endif

#if (!defined(ui64_inc))
#include <ui64.h>
#endif

/****************************************************************************
NAME:  A_DecodeTypeClass

PURPOSE:  Decode the Class and Form bits from an ASN.1 type field.
          The data stream is read using the local I/O package.
          The stream pointer is NOT advanced, leaving it pointing to the
          start of the type field, ready for a subsequent call to
          A_DecodeTypeValue.

CAVEAT:   The user should call this return *BEFORE* calling
          A_DecodeTypeValue.

PARAMETERS:  LCL_FILE *     A stream descriptor (already open)

RETURNS:  OCTET_T           The Class and Form bits

RESTRICTIONS:  It is assumed that the stream is not at EOF.
****************************************************************************/

#define A_DecodeTypeClass(L) ((OCTET_T) (SNMP_LclPeekc((LCL_FILE *)(L)) &   \
                                         A_IDCF_MASK))

/****************************************************************************
Decoding errors
****************************************************************************/
#define AE_PREMATURE_END                1
#define AE_INDEFINITE_LENGTH            2
#define AE_WRONG_VALUE                  3
#define AE_WRONG_TYPE                   4
#define AE_WRONG_LENGTH                 5
#define AE_ALLOC_FAILURE                6

extern  ATVALUE_T       A_DecodeTypeValue       __((LCL_FILE *, int *));
extern  ALENGTH_T       A_DecodeLength          __((LCL_FILE *, int *));
extern  void            A_DecodeOctetStringData __((LCL_FILE *, ALENGTH_T,
                                                    EBUFFER_T *, int *));
extern  void            A_DecodeOctetString     __((LCL_FILE *, EBUFFER_T *,
                                                    int *));
extern  void            A_DecodeOctetStringWTC  __((LCL_FILE *, EBUFFER_T *,
                                                    int *, ATVALUE_T,
                                                    OCTET_T));
extern  bits8_t         A_DecodeOctetWTC        __((LCL_FILE *, int *,
                                                    ATVALUE_T, bits8_t));
extern  INT_32_T        A_DecodeIntegerData     __((LCL_FILE *, ALENGTH_T,
                                                    int *));
extern  INT_32_T        A_DecodeInteger         __((LCL_FILE *, int *));
extern  INT_32_T        SNMP_DecodeIntegerWTC      __((LCL_FILE *, int *,
                                                    ATVALUE_T, OCTET_T));
extern  void            A_DecodeObjectIdData    __((LCL_FILE *, ALENGTH_T,
                                                    OBJ_ID_T *, int *));
extern  void            A_DecodeObjectId        __((LCL_FILE *, OBJ_ID_T *,
                                                    int *));
extern  void            A_DecodeObjectIdWTC     __((LCL_FILE *, OBJ_ID_T *,
                                                    int *, ATVALUE_T,
                                                    OCTET_T));

/* We only install some functions if their types are installed */
#if (ENVOY_USE_V2_TYPES)
extern  void            A_DecodeInteger64Data   __((LCL_FILE *, ALENGTH_T, 
                                                    UINT_64_T *, int *));
extern  void            A_DecodeInteger64       __((LCL_FILE *, UINT_64_T *,
                                                    int *));
#endif

#ifdef __cplusplus
}
#endif

#endif /* decode_inc */
